<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>第二课堂-登录</title>
<meta name="Generator" content="Sublime Text">
<meta name="Author" content="刘先生">
<meta name="keywords" content="">
<!--引入css文件-->
<link rel="stylesheet" type="text/css" href="__ROOT__/static/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="__ROOT__/static/font-awesome/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="__ROOT__/static/css/animate.css">
<link rel="stylesheet" type="text/css" href="__ROOT__/static/css/admin-style.css">
<!--引入外部jQuery插件-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!--引入外部layer弹层插件插件-->
<script type="text/javascript" src="__ROOT__/static/lay/modules/layer.js"></script>
</head>
<body class="gray-bg">
    <div class="middle-box text-center loginscreen animated fadeInDown">
    	<div>
    		<div>
    			<h1 class="logo-name">GX</h1>
    		</div>
    		<h3>第二课堂后台</h3>
    		<form action="/admin/Service/login" method="post" id="form" name="form" autocomplete="false" accept-charset="utf-8">
    			<div class="form-group">
    				<input type="text" name="username" class="form-control" placeholder="用户名">
    			</div>
    			<div class="form-group">
    				<input type="password" name="password" class="form-control" placeholder="密码">
    			</div>
    			<button type="submit" class="btn btn-primary block full-width m-b">登录</button>
    		</form>
    	</div>
    </div>

<!--Ajax异步提交开始-->
<script type="text/javascript">
    $('form').submit(function(){
        //获取用户名
        var username = $("input[name = 'username']").val();
        //获取密码
        var password = $("input[name = 'password']").val();
        //获取验证码
        // var code = $("#code").val();
        //判断用户名、密码、验证码是否为空
        if(!username){
            layer.msg('用户名不能为空',{time : 2000});
            return false;
        }
        if(!password){
            layer.msg('密码不能为空',{time : 2000});
            return false;
        }
       /* if(!code){
            layer.msg('验证码不能为空',{time : 2000});
            return false;
        }*/

        //获取跳转路径，也就是action的值
        var url = $(this).attr('action');
        $.ajax({
            type : "post",  //post请求
            url : url,   //发送请求的地址，这里是checkLogin方法
            // data:{username:username,password:password,code:code}
            data:{username:username,password:password},  //传递的参数
            success:function(res){     //回调函数，res参数是从checkLogin的方法返回的值
                if(res.status){
                    layer.msg(res.message,{time:1000},function(){
                        window.location.href = "/admin/index/mantype";
                    });
                }else{
                    //刷新验证码
                    // $(".reloadverify").click();
                    layer.msg(res.message,{time : 2000});
                }
            }
        });
        return false;
    });
</script>
<!--ajax异步提交-->
</body>
</html>